package com.daohang361.imqq.decoder;

import com.daohang361.imqq.Asycore.QQUser;
import com.daohang361.imqq.tool.MyUtil;

public class Decoder17 extends AbstractDecoder {
@Override
public QQUser decode() throws Exception {
	myArray.decryptRemain(sessionQQ.getAttr("SessionKey"));
	decryptAll=myArray.extract(0, 15);
	sessionQQ.setCommand(0x17);
	sessionQQ.setSend(decryptAll);
	sessionQQ.addAttr("17Pakage", myArray.getPakage());
	sessionQQ.setPakage(sessionQQ.getPakage()+1);//登陆包自动增长
	
	print();
	
	return sessionQQ;
	
	}

	private void print( ){
		try {
			myArray.extract(0, 7);
			myArray.delete();
			byte[] qqGroup=myArray.extract(0, 3);
			myArray.delete();
			myArray.extract(0,0);//
			myArray.delete();
			byte[] sendQQ=myArray.extract(0, 3);
			myArray.delete();
			myArray.extract(0, 3);
			myArray.delete();
			byte[] time=myArray.extract(0,3);
			myArray.delete();
			myArray.extract(0, 59);
			myArray.delete();
			int length=MyUtil.bytes2Integer(myArray.extract(0, 1));
			if(length==0)
				return;
			myArray.delete();
			byte[] contex=myArray.extract(0, length-1);
			
			System.out.println("群["+MyUtil.bytes2Integer(qqGroup)+"]时间["+MyUtil.bytes2Time(time)+"] 用户 ["+MyUtil.bytes2Integer(sendQQ)+"]消息:");
			System.out.println(new String(contex,"UTF-8"));
		} catch (Exception e) {
			System.out.println("17尝试按群消息转换出错了");
			//			e.printStackTrace();
		}
	}
}
